package org.example;

public class Test2 {
    //leetcode 赎金信
    //https://leetcode.cn/problems/ransom-note/description/?envType=study-plan-v2&envId=top-interview-150
    public boolean canConstruct(String ransomNote, String magazine) {
        int[] hash = new int[26];
        for (char c : ransomNote.toCharArray()) {
            hash[c-'a']++;
        }
        for (char c : magazine.toCharArray()) {
            hash[c-'a']--;
        }
        for (int n : hash) {
            if (n > 0) return false;
        }
        return true;
    }
}
